package com.controller;
import com.pojo.ShopRecommend;
import com.service.ShopRecommendService;
import com.util.ServerResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2020/3/20.
 */
@Api(tags = "商铺推荐菜的API")
@Controller
public class ShopRecommendController {
    @Autowired
    private ShopRecommendService shopRecommendService;
    @ApiOperation(value ="添加商铺的推荐菜",notes ="添加商铺的推荐菜" )
    @PostMapping("/shopRecommend")
    @ResponseBody
    public ServerResponse add(ShopRecommend shopRecommend){
        // ServerResponse serverResponse =
        //System.out.println("serverResponse:"+serverResponse);
        return shopRecommendService.save(shopRecommend);
    }

    /*
      根据id删除用户，假删除状态改为0
   */ @ApiOperation(value = "根据id删除商铺推荐菜",notes ="修改推荐菜的状态")
    @DeleteMapping("/shopRecommend/{id}")
    @ResponseBody
    public ServerResponse del(@PathVariable("id")String id){
        ServerResponse serverResponse = shopRecommendService.modifyStatus(Integer.valueOf(id));
        System.out.println("serverResponse:"+serverResponse);
        return serverResponse;
    }

    @ApiOperation(value ="修改推荐菜信息",notes ="" )
    @PutMapping("/shopRecommend")
    @ResponseBody
    public ServerResponse upd(ShopRecommend shopRecommend){
        System.out.println(shopRecommend);
        ServerResponse serverResponse = shopRecommendService.modify(shopRecommend);
        return serverResponse;
    }
    /*
      根据id查询用户
   */
    @ApiOperation(value ="根据菜品id查询菜品信息")
    @GetMapping("/shopRecommend/{id}")
    @ResponseBody
    public ServerResponse findById(@PathVariable("id") String id){
        System.out.println(id);
        ServerResponse serverResponse = shopRecommendService.getById(Integer.valueOf(id));
        return serverResponse;
    }

    @ApiOperation(value ="查询推荐菜信息")
    @GetMapping("/shopRecommend")
    @ResponseBody
    public ServerResponse findAll(){
        ServerResponse serverResponse = shopRecommendService.getAll();
        return serverResponse;
    }
}
